<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
</head>
<body>
<div id="app">
    <input type="text" v-model="name"><br>
    <input type="radio" v-model="sex" name="sex" value="男">男
    <input type="radio" v-model="sex" name="sex" value="女">女<br>
    <button @click="save">添加</button>
    <ul>
        <li v-for="u in users" >{{u.name}}:{{u.sex}}</li>
    </ul>
</div>
<script>
    let app=new Vue({
        el:"#app",
        data:{
            users:[],
            name:'',
            sex:'男'
        },
        methods:{
            save:function () {
                //把用户名和密码组建一个json对象
                let u={name:this.name,sex:this.sex};
                //把json对象存放在数组中
                this.users.push(u);
            }
        }
    });
</script>
</body>
</html>